package com.suddev.bigdata.core

import com.vividsolutions.jts.geom.{Coordinate, GeometryFactory}

/**
  *
  * @author Rand
  * @date 2020/2/11 0011
  */
object GeoDemoApp {
  def main(args: Array[String]): Unit = {
    // 创建一个坐标
    val coord = new Coordinate(-84.01, 34.01)
    // 实例化Geometry工厂类
    val factory = new GeometryFactory()
    // 创建Point
    val pointObject = factory.createPoint(coord)
    // 创建Polygon
    val coordinates = new Array[Coordinate](5)
    coordinates(0) = new Coordinate(0,0)
    coordinates(1) = new Coordinate(0,4)
    coordinates(2) = new Coordinate(4,4)
    coordinates(3) = new Coordinate(4,0)
    // 多边形是闭合的，所有最后一个点就是第一个点
    coordinates(4) = coordinates(0)
    val polygonObject = factory.createPolygon(coordinates)
    // 创建LineString
    val coordinates2 = new Array[Coordinate](4)
    coordinates2(0) = new Coordinate(0,0)
    coordinates2(1) = new Coordinate(0,4)
    coordinates2(2) = new Coordinate(4,4)
    coordinates2(3) = new Coordinate(4,0)
    val linestringObject = factory.createLineString(coordinates2)
  }
}
